﻿Imports System.ServiceModel

' NOTE: If you change the class name "ITyrrantUserService" here, you must also update the reference to "ITyrrantUserService" in Web.config.
<ServiceContract()> _
Public Interface ITyranntUserService

    ' User management routines 
    <OperationContract()> _
    Function Login(ByVal loginData As LoginType) As TokenType
    <OperationContract()> _
    Function Logout(ByVal token As String) As String
    <OperationContract()> _
    Function Register(ByVal registerData As RegisterType) As TokenType
    <OperationContract()> _
    Function ChangePassword(ByVal token As String, ByVal userID As Integer, ByVal newPasword As String) As String
    <OperationContract()> _
    Function GetUsers(ByVal token As String) As String
    <OperationContract()> _
    Function RemoveUser(ByVal token As String, ByVal userID As Integer) As String
    <OperationContract()> _
    Function GetUserGroup(ByVal token As String) As IntegerType
    <OperationContract()> _
    Function ChangeUserGroup(ByVal token As String, ByVal userID As Integer, ByVal newGroup As Integer) As String

    ' General Admin routines
    <OperationContract()> _
    Function SetMOTD(ByVal token As String, ByVal message As String) As String

End Interface


<DataContract()> _
Public Class LoginType
    Private usernameString As String
    Private passwordString As String

    <DataMember()> _
    Public Property Username() As String
        Get
            Return Me.usernameString
        End Get
        Set(ByVal value As String)
            Me.usernameString = value
        End Set
    End Property

    <DataMember()> _
    Public Property Password() As String
        Get
            Return Me.passwordString
        End Get
        Set(ByVal value As String)
            Me.passwordString = value
        End Set
    End Property
End Class

<DataContract()> _
Public Class RegisterType
    Private _username As String
    Private _password As String
    Private _alias As String
    Private _email As String

    <DataMember()> _
    Public Property Username() As String
        Get
            Return _username
        End Get
        Set(ByVal value As String)
            _username = value
        End Set
    End Property

    <DataMember()> _
    Public Property Password() As String
        Get
            Return _password
        End Get
        Set(ByVal value As String)
            _password = value
        End Set
    End Property

    <DataMember()> _
    Public Property UserAlias() As String
        Get
            Return _alias
        End Get
        Set(ByVal value As String)
            _alias = value
        End Set
    End Property

    <DataMember()> _
    Public Property Email() As String
        Get
            Return _email
        End Get
        Set(ByVal value As String)
            _email = value
        End Set
    End Property
End Class

<DataContract()> _
Public Class IntegerType
    Private _integer As Integer
    Private _error As String

    <DataMember()> _
    Public Property IntegerValue() As Integer
        Get
            Return _integer
        End Get
        Set(ByVal value As Integer)
            _integer = value
        End Set
    End Property

    <DataMember()> _
    Public Property ErrorMessage() As String
        Get
            Return _error
        End Get
        Set(ByVal value As String)
            _error = value
        End Set
    End Property
End Class

<DataContract()> _
Public Class TokenType
    Private _userGroup As IntegerType
    Private _tokenString As String
    Private _alias As String

    <DataMember()> _
    Public Property UserGroup() As IntegerType
        Get
            Return _userGroup
        End Get
        Set(ByVal value As IntegerType)
            _userGroup = value
        End Set
    End Property

    <DataMember()> _
    Public Property TokenString() As String
        Get
            Return _tokenString
        End Get
        Set(ByVal value As String)
            _tokenString = value
        End Set
    End Property

    <DataMember()> _
    Public Property UserAlias() As String
        Get
            Return _alias
        End Get
        Set(ByVal value As String)
            _alias = value
        End Set
    End Property
End Class